package org.andao.commons.model;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.andao.core.base.model.RootModel;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;


/**
 * 系统消息接受者.
 * @author Marco.hu(hzg139@163.com)
 *
 */
@Entity
@Table(name="seewo_sys_msgreceiver")  
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class MessageReceiver extends RootModel{

	private static final long serialVersionUID = 3635644353406131051L;
	
	@OneToOne(optional = true, cascade = { CascadeType.MERGE,CascadeType.PERSIST }, fetch = FetchType.LAZY)
	@JoinColumn(name = "MSGID")
	private Message message;//消息
	
	@Column(name="RECEIVETYPE",nullable=false)
	private String receiveType;//消息接收类型 org - 按组织/ role - 按角色/ user - 按用户
	
	@Column(name="ORGUNITCODES")
	private String orgUnitCodes;//接受者：组织编码集合,使用',’分割
	
	@Column(name="ROLECODES")
	private String roleCodes;//接收者：角色编码集合,使用','分割
	
	@Lob
	@Basic(fetch = FetchType.LAZY) 
	@Column(name="USERIDS")
	private String userIds;//接受者ID：集合，使用','分割

	@Transient
	private String orgUnitNames;//组织名称集
	
	@Transient
	private String roleNames;	//角色名称集
	
	@Transient
	private String userCnNames;//用户名集
	
	public Message getMessage() {
		return message;
	}

	public void setMessage(Message message) {
		this.message = message;
	}

	public String getOrgUnitCodes() {
		return orgUnitCodes;
	}

	public void setOrgUnitCodes(String orgUnitCodes) {
		this.orgUnitCodes = orgUnitCodes;
	}

	public String getReceiveType() {
		return receiveType;
	}

	public void setReceiveType(String receiveType) {
		this.receiveType = receiveType;
	}

	public String getRoleCodes() {
		return roleCodes;
	}

	public void setRoleCodes(String roleCodes) {
		this.roleCodes = roleCodes;
	}


	public String getUserIds() {
		return userIds;
	}

	public void setUserIds(String userIds) {
		this.userIds = userIds;
	}

	public String getOrgUnitNames() {
		return orgUnitNames;
	}

	public void setOrgUnitNames(String orgUnitNames) {
		this.orgUnitNames = orgUnitNames;
	}

	public String getRoleNames() {
		return roleNames;
	}

	public void setRoleNames(String roleNames) {
		this.roleNames = roleNames;
	}

	public String getUserCnNames() {
		return userCnNames;
	}

	public void setUserCnNames(String userCnNames) {
		this.userCnNames = userCnNames;
	}
	
	
}
